<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Usersincomes extends Model
{
    protected $table = 'users_incomes';
    protected $primaryKey = 'id';

    public static function getbatchIncomes($users_id,$batch)
    {
        return self::where("users_id", $users_id)->where("batch", $batch)->first();
    }

    public static function getUsersInvitation($users_id)
    {
        return self::where("users_id", $users_id)->first();
    }

    public static function addbatchIncomes($users_id,$batch,$money,$commission)
    {
        return self::insert(["users_id"=>$users_id,"batch"=>$batch,"money"=>$money,"commission"=>$commission,"created_at"=>time()]);
    }

    public static function updatebatchIncomes($id,$money,$commission)
    {
        return self::where("id", $id)->update(["money"=>$money,"commission"=>$commission]);
    }
}
